<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
  <%-- <%@include file="../../common/taglib.jsp"%> --%>
 <style>
 #pageTableSett .more{
 	max-width:200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
 }
 </style>
      <div class="row">
        <div class="col-xs-12">
          <div class="box">
            <div class="box-header">
              <h3 class="box-title">
              </h3>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
            <div class="clearfix">
					<div class="col-md-3">
						<div class="input-group date ">
							<div class="input-group-addon">
								<i class="fa fa-calendar"></i>
							</div>
							<input type="text" class="form-control pull-right" id="beginDateSett" placeholder="开始时间...">
							<input type="text" class="form-control pull-right" id="endDateSett" placeholder="结束时间...">
						</div>
					</div>
					<div class="col-md-3">
						<div class="input-group">
							<span class="input-group-addon"><i class="fa fa-search"></i></span>
							<input type="text" class="form-control" id="merchantRequestNoSett" placeholder="商户订单号...">
							<select class="form-control" id="statusSett">
								<option value="">选择结算状态</option>
								<option value="WAIT_CONFIRM">等待审核</option>
								<option value="CANCEL_FAIL">审核通过</option>
								<option value="CANCEL_FAIL">审核不通过</option>
								<option value="REMITTING">打款中</option>
								<option value="REMIT_SUCCESS">打款成功</option>
								<option value="REMIT_FAIL">打款失败</option>
								<option value="BOOKING_SUCCESS">已销账</option>
							</select>
						</div>
					</div>
					<div class="col-md-3">
						<button type="submit" id="searchSett" class="btn btn-primary">搜索</button>
						<button type="submit" id="exportSett" class="btn btn-primary">导出</button>
					</div>
				</div>
				
				<div>&nbsp;&nbsp;结算总金额：<font color="red" id="amountTH"></font>&nbsp;&nbsp;&nbsp;&nbsp;结算总手续费：<font color="red" id="feeTH"></font></div>
              <table id="pageTableSett" class="table table-bordered table-hover">
              
                <thead>
                <tr>
                  <th>商户订单号</th>
                  <th>结算金额</th>
                  <th>结算手续费</th>
                  <th>银行名称</th>
				  <th>开户名</th>
                  <th>开户账户</th>
                  <th>结算状态</th>
                  <th>创建时间</th>
                  <th >备注</th>
                </tr>
                </thead>
                <tbody>
                </tbody>
               
              </table>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
      </div>
     <!-- DataTables -->

<%-- <%@include file="./add.jsp" %> --%>
<script src="${baseURL }/lte/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="${baseURL }/lte/plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- page script -->
<script>
$("#searchSett").on("click",function(){
	searchSett();
	sumAmountSett();
});

//初始化时间选择器
$('#beginDateSett').datepicker({
	autoclose: true,
	defaultDate:'-1M',
	beforeShowDay: $.noop,
	calendarWeeks: false,
	clearBtn: false,
	daysOfWeekDisabled: [],
	endDate: Infinity,
	forceParse: true,
	format: 'yyyy-mm-dd',
	keyboardNavigation: true,
	language: 'cn',
	minViewMode: 0,
	multidate: false,
	multidateSeparator: ',',
	orientation: "auto",
	rtl: false,
	startDate: -Infinity,
	startView: 0,
	todayBtn: false,
	todayHighlight: false,
	weekStart: 0
});

$('#endDateSett').datepicker({
	autoclose: true,
	defaultDate:'-1M',
	beforeShowDay: $.noop,
	calendarWeeks: false,
	clearBtn: false,
	daysOfWeekDisabled: [],
	endDate: Infinity,
	forceParse: true,
	format: 'yyyy-mm-dd',
	keyboardNavigation: true,
	language: 'cn',
	minViewMode: 0,
	multidate: false,
	multidateSeparator: ',',
	orientation: "auto",
	rtl: false,
	startDate: -Infinity,
	startView: 0,
	todayBtn: false,
	todayHighlight: false,
	weekStart: 0
});

function retrieveData( sSource, aoData, fnCallback ) {      
	aoData.push({ "name": "beginDate", "value": $("#beginDateSett").val()},{ "name": "endDate", "value": $("#endDateSett").val()},
			{ "name": "merchantRequestNo", "value": $("#merchantRequestNoSett").val()},{ "name": "status", "value": $("#statusSett").val()}); 
    $.ajax( {     
        "type": "POST",      
        "contentType": "application/json",     
        "url": sSource,      
        "dataType": "json",     
        "data": JSON.stringify(aoData), //以json格式传递     
        "success": function(resp) {     
            fnCallback(resp); //服务器端返回的对象的returnObject部分是要求的格式    
        }     
    });      
}    

var oTableSett = null;     

$(function() {     
    searchSett();
    sumAmountSett();
} );     
    
//“检索”按钮的处理函数     
function searchSett() {     
    if (oTableSett == null) { //仅第一次检索时初始化Datatable     
        $("#pageTableSett").show();     
        oTableSett = $('#pageTableSett').dataTable( {     
            "bAutoWidth": false,                    //不自动计算列宽度     
            "aoColumns": [                          //设定各列宽度     
                            {"mData" : "merchantRequestNo"},           
                            {"mData" : "settAmount"},
                            {"mData" : "settFee"},
                            {"mData" : "bankName"},
                            {"mData" : "bankAccountName"},
                            {"mData" : "bankAccountNo"},
                            {"mData" : "settStatusDesc"},
                            {"mData" : "createTimeDesc"},
                            {"mData" : "remitRemark"}
                        ],
             "columnDefs": [ {
                 "targets": -1,
                 "data": null,
                 "render": function(data){
                	 console.log(data)
     				return '<div class="more" title="'+data+'">'+data+'</div>'
     			}
             } ],
            "bProcessing": true,                    //加载数据时显示正在加载信息     
            "bServerSide": true,                    //指定从服务器端获取数据     
            "bFilter": false,                       //不使用过滤功能     
            "bLengthChange": false,                 //用户不可改变每页显示数量     
            "iDisplayLength": 10,                    //每页显示10条数据     
            "sAjaxSource": "${baseURL }/merchant/sett/ajaxSettList",//获取数据的url     
            "fnServerData": retrieveData,           //获取数据的处理函数     
            "sPaginationType": "full",      //翻页界面类型     
            "searching": false,
            "ordering": false,
            "oLanguage": {                          //汉化     
                "sZeroRecords": "没有检索到数据",     
                "sInfo": "总共有 _TOTAL_ 条记录",     
                "sInfoEmtpy": "没有数据",     
                "sProcessing": "正在加载数据...",     
                "oPaginate": {     
                    "sFirst": "首页",     
                    "sPrevious": "前一页",     
                    "sNext": "后一页",     
                    "sLast": "尾页"    
                }     
            }     
        });     
    }     
    
    //刷新Datatable，会自动激发retrieveData     
    oTableSett.fnDraw();     
}    
function sumAmountSett(){
	$("#amountTH").html("");
	$("#feeTH").html("");
	var beginDate = $("#beginDateSett").val();
	var endDate = $("#endDateSett").val();
	var merchantRequestNo = $("#merchantRequestNoSett").val();
	var status = $("#statusSett").val();
	$.ajax({  
        type: "GET",
        data : {
        	beginDate : beginDate,
        	endDate : endDate,
        	merchantRequestNo : merchantRequestNo,
        	status : status
		},
        dataType:'json',
        url: "${baseURL }/merchant/sett/sumAmountByUserNo",
        //请求成功完成后要执行的方法  
        success: function(result){
        	$("#amountTH").html(result.sumAmount);
        	$("#feeTH").html(result.sumFee);
        },  
        error : function() {
        	 
        }   
    });
}
$("#exportSett").on("click",function(){
	exportReportSett();
});

function exportReportSett(){
	var beginDate = $("#beginDateSett").val();
	var endDate = $("#endDateSett").val();
	var merchantRequestNo = $("#merchantRequestNoSett").val();
	var status = $("#statusSett").val();
	window.location.href = "${baseURL }/merchant/sett/listSettRecordExportExecl?beginDate=" + beginDate + "&endDate=" + endDate + 
	  "&merchantRequestNo=" + merchantRequestNo + "&status=" + status;
}

</script>